local jiang = fk.CreateSkill {
  name = "lvshi__jiang",
}

Fk:loadTranslationTable{
  ["lvshi__jiang"] = "激昂",
  [":lvshi__jiang"] = "出牌阶段，你可摸一张牌并与一名手牌数大于此回合以此法选择过的角色拼点，若你赢，你可摸一张牌并视为对一名体力值大于此回合选择过的角色使用【决斗】，若你没赢，你于此回合不能使用牌。",
  ["#lvshi__jiang-invoke"] = "激昂：你可拼点（须选择手牌数大于此回合以此法选择过的角色）",
  ["#lvshi__jiang-duel"] = "激昂：你可决斗（须选择体力值大于此回合以此法选择过的角色）",
  ["@lvshi__jiang-turn"] = "激昂",

  ["$lvshi__jiang1"] = "剑锋所指，敌莫敢当！",
  ["$lvshi__jiang2"] = "所向披靡，进退自如！",
}

jiang:addEffect("active", {
  anim_type = "offensive",
  target_num = 1,
  card_num = 0,
  prompt = "#lvshi__jiang-invoke",
  can_use = Util.TrueFunc,
  card_filter = Util.FalseFunc,
  target_filter = function(self, player, to_select, selected)
    return to_select:getHandcardNum() > player:getMark("@lvshi__jiang-turn") and player:canPindian(to_select, true)
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    room:setPlayerMark(player, "@lvshi__jiang-turn", target:getHandcardNum())
    player:drawCards(1, jiang.name)
    local pindianData = player:pindian({ target }, jiang.name)
    if pindianData.results[target].winner == player and not player.dead then
      local to = room:askToChoosePlayers(player, {
        targets = table.filter(room:getOtherPlayers(player), function (p)
          return player:canUseTo(Fk:cloneCard("lvshi__duel"), p) and (p.hp > player:getMark("lvshi__jiang_duel-turn")
          or player:getMark("lvshi__jiang_duel-turn") == 0)
        end),
        max_num = 1,
        min_num = 1,
        skill_name = jiang.name,
        cancelable = true,
        prompt = "#lvshi__jiang-duel",
      })
      if #to > 0 then
        room:setPlayerMark(player, "lvshi__jiang_duel-turn", to[1].hp)
        player:drawCards(1, jiang.name)
        room:useVirtualCard("lvshi__duel", nil, player, to[1])
      end
    else
      room:addPlayerMark(player, "lvshi__jiang_prohibit-turn")
    end
  end,
})

jiang:addEffect("prohibit", {
  prohibit_use = function(self, player, card)
    return player:getMark("lvshi__jiang_prohibit-turn") > 0
  end,
})

return jiang
